import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer

import xbmcgui

class ConfirmBox(xbmcgui.Window):
	def __init__(self):
		
		self.selectedOption = '';
	
		self.acceptCallButton = xbmcgui.ControlButton(10,10,200,50,'^');
		self.acceptVideoCallButton = xbmcgui.ControlButton(10,300,50,'^');
		self.declineButton = xbmcgui.ControlButton(10,500,50,'^');
		
		self.addControl(self.acceptCallButton)
		self.addControl(self.videoCallButton)
		self.addControl(self.declineButton)
		
		self.doModal()
		pass
		
	def onControl(self, control):
		if control == self.acceptCallButton :
			self.selectedOption = "ACCEPT_CALL"
		elif control == self.acceptVideoCallButton :
			self.selectedOption = "ACCEPT_VIDEO_CALL"
		elif control == self.declineButton :
			self.selectedOption = "DECLINE_CALL"
		self.close()
		
	def getSelectedOption(self):
		return self.selectedOption

def callAlert() :
	c = ConfirmBox()
	result = c.getSelectedOption()
	return result

if __name__ == '__main__' :
	server = SimpleXMLRPCServer(('localhost', 8888))
	#server = SimpleThreadedXMLRPCServer(('localhost', 8888))
	server.register_function(callAlert)
	server.serve_forever()
	
	
	
